package com.afdor.rws.event.driven.config;

import com.afdor.rws.annotation.extension.Extension;
import com.afdor.rws.annotation.extension.SPI;
import com.afdor.rws.event.driven.commons.Constants;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;

import java.io.Serializable;

/**
 * 生成者相关配置<br/>
 * Extension : prototype
 *
 * @author 悭梵
 * @date Created in 2018-11-21 15:45
 */
@Getter
@SPI(Constants.DEFAULT_COMPONENT_CONFIG_EXTENSION_NAME)
@Extension(value = Constants.DEFAULT_COMPONENT_CONFIG_EXTENSION_NAME, scope = Extension.Scope.PROTOTYPE, interfaceClass = EventProducerConfig.class)
public class EventProducerConfig<BC extends EventConfig> extends BaseEventConfig<BC> implements Serializable, Cloneable {

    /**
     * 事件源名称
     */
    @Setter
    @NonNull
    private String eventSourceName;
    /**
     * 生成者名称。默认default
     */
    @Setter
    private String producerName = "default";
    /**
     * 事务策略名称
     */
    @Setter
    private String transactionStrategyName;
    /**
     * 生产者扩展点名称，必填。各种实现方式，存在默认值不一样情况
     */
    @Setter
    @NonNull
    private String eventProducerStrategyName;
    /**
     * 事件序列化扩展点名称，必填。各种实现方式，存在默认值不一样情况
     */
    @Setter
    @NonNull
    private String serializationStrategyName;
    /**
     * 构造器初始化入参，为空，则调用无参构造函数
     */
    private Object[] constructorArgs;

    public EventProducerConfig() {
    }

    public EventProducerConfig(@NonNull final BC eventConfig) {
        setEventConfig(eventConfig);
    }

    public void setConstructorArgs(Object... args) {
        this.constructorArgs = args;
    }

}
